﻿CREATE FUNCTION [dbo].[fs_WorkflowByGroup]
(@GroupName sysname = '')
RETURNS TABLE
AS
RETURN (
SELECT DISTINCT WFG.MenuID, WFG.NextMenuID,WF.MenuName, WF.NextMenuName,
								WF.WFIndex, WF.NextWFIndex, WF.Direction,
								WF.IsQueue, WF.IsStatus, WF.ParentMenuID, WF.NextParentMenuID
FROM t_Workflow_Groups AS WFG
INNER JOIN v_WorkFlow WF ON WFG.MenuID = WF.MenuID AND WFG.NextMenuID = WF.NextMenuID
WHERE @GroupName IN (WFG.GroupName,'')
)



